<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="../../0505/js/jq.js"></script>
    <script>
        // $.ajax({
        //     url: 'http://localhost:3000/play/hot',
        //     success(res) {
        //         console.log(res);
        //     }
        // })
        let p1 = (url)=>{
            // resolve, reject 是promise注入的两个函数作为参数
            return new Promise((resolve, reject) => {
                $.ajax({
                    url,
                    success(res) {
                        resolve(res)
                    },
                    error(err) {
                        reject(err)
                    }
                })
            })
        }
        p1('http://localhost:3000/play/hot')
        .then(res => {
            console.log(11, res);
            
            
        },err => {
            console.log(22, err);
        })
        .then(res => {
            // 第二个数据
            p1('http://localhost:3000/play/category')
                console.log(res);
            })
    </script>
</body>
</html>